﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Objects;

public partial class UserRole : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void UserRoleFormView_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName.ToUpper() == "CANCEL")
            UserRoleFormView.ChangeMode(FormViewMode.Insert);
    }
    protected void UserRoleGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        UserRoleFormView.PageIndex = (UserRoleGridView.PageSize * UserRoleGridView.PageIndex) + UserRoleGridView.SelectedIndex;
        UserRoleFormView.ChangeMode(FormViewMode.Edit);
        UserRoleGridView.DataBind();
        UserRoleGridView.SelectedIndex = -1;
    }
    protected void ClearImageButton_Click(object sender, ImageClickEventArgs e)
    {
        FirstNameTextBox.Text = LastNameTextBox.Text = UserNoTextBox.Text = string.Empty;
        ClearImageButton.OnClientClick = "return false;";
    }
    protected void SearchImageButton_Click(object sender, ImageClickEventArgs e)
    {
        UserRoleGridView.PageSize = (PageSizeDropDownList.SelectedIndex == -1 || PageSizeDropDownList.SelectedValue == "0" ? 5 : Convert.ToInt32(PageSizeDropDownList.SelectedValue));
        if (FirstNameTextBox.Text != string.Empty ||
            LastNameTextBox.Text != string.Empty ||
            UserNoTextBox.Text != string.Empty)
            ClearImageButton.OnClientClick = string.Empty;
        else
            ClearImageButton_Click(sender, e);
    }
    protected void UserRoleEntityDataSource_Command(object sender, EntityDataSourceChangedEventArgs e)
    {
        UserRoleGridView.DataBind();
        UserRoleFormView.ChangeMode(FormViewMode.Insert);
    }
    protected void UserGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        UserLabel.Text = string.Format("{0}", UserGridView.Rows[UserGridView.SelectedIndex].Cells[2].Text);
        UserIDHiddenField.Value = UserGridView.SelectedValue.ToString();
        MultiView.SetActiveView(EditView);
    }
    protected void InsertButton_Click(object sender, ImageClickEventArgs e)
    {
        ((HiddenField)UserRoleFormView.FindControl("UserIDHiddenField")).Value = UserIDHiddenField.Value;
    }
    protected void ReturnLinkButton_Click(object sender, EventArgs e)
    {
        MultiView.SetActiveView(ShowView);
    }
}


